//
//  ChartContext.m
//  Pods
//
//  Created by E.F.B on 15-5-5.
//
//

#import "ChartContext.h"

static ChartContext* s_instance = nil;

@interface ChartContext()

@property (nonatomic, retain) NSMutableDictionary* dic;

@end


@implementation ChartContext

@synthesize dic = _dic;

-(void)dealloc{
    [super dealloc];
}

+ (id)instance {
    
    if (s_instance == nil)
    {
        s_instance = [[super allocWithZone:NULL] init];
        s_instance.dic = [[[NSMutableDictionary alloc] init] autorelease];
    }
    
    return s_instance;
}


+ (id)allocWithZone:(NSZone *)zone
{
    return s_instance;
}

- (id)copyWithZone:(NSZone *)zone {
    return self;
}

- (id)retain {
    return self;
}

- (NSUInteger)retainCount {
    return NSUIntegerMax; //denotes an object that cannot be released
}

- (oneway void)release {
    //do nothing
}

- (id)autorelease {
    return self;
}

- (id)objectForKey:(id)key {
    
    return [self.dic objectForKey:key];
}

- (id)setValue:(id)value forKey:(NSString *)key {
    id old = [self objectForKey:key];
    [self.dic setValue:value forKey:key];
    return old;
}

- (void)reset
{
    NSString * nightmode = [[self.dic objectForKey:kContextNightModel] copy];
    NSString *chartNightmode = [[self.dic objectForKey:kContextChartNightModel] copy];
    
    [self.dic removeAllObjects];
    
    [self setValue:nightmode forKey:kContextNightModel];
    [self setValue:chartNightmode forKey:kContextChartNightModel];
    
    [nightmode release];
    [chartNightmode release];
    
}

- (NSDictionary *)dictionary
{
    return [NSDictionary dictionaryWithDictionary:self.dic];
}

@end
